Unit BDojoxFloatingPaneUnit;

{$mode objfpc}{$H+}

Interface

Uses
  Classes, SysUtils, BDojoSessionUnit, BDojoxContentPaneUnit;

Type

{ BDojoxFloatingPaneClass }

 BDojoxFloatingPaneClass = Class(BDojoxContentPaneClass)
  Private
    bDockable: Boolean;
    bDuration: Integer;
    bMaxable: Boolean;
    bResizable: Boolean;
    bResizeAxis: String;
    Procedure SetDockable(aValue: Boolean);
    Procedure SetDuration(aValue: Integer);
    Procedure SetMaxable(aValue: Boolean);
    Procedure SetResizable(aValue: Boolean);
    Procedure SetResizeAxis(aValue: String);
  Public
    //** Allow minimizing of pane if true
    Property Dockable: Boolean Read bDockable Write SetDockable;
    //** Time is MS to spend toggling in/out node
    Property Duration: Integer Read bDuration Write SetDuration;
    //** Horrible param name for "Can you maximize this floating pane?"
    Property Maxable: Boolean Read bMaxable Write SetMaxable;
    //** Allow resizing of pane true if true
    Property Resizable: Boolean Read bResizable Write SetResizable;
    //** One of: x | xy | y to limit pane's sizing direction
    Property ResizeAxis: String Read bResizeAxis Write SetResizeAxis;

    //** bring this FloatingPane above all other panes
    Procedure BringToTop;
    //** Close and destroy this widget
    Procedure Close;
    //** Close, but do not destroy this FloatingPane
    Procedure Hide;
    //** Make this FloatingPane full-screen (viewport)
    Procedure Maximize;
    //** Hide and dock the FloatingPane
    Procedure Minimize;
    //** DojoPas Exctension! Look for BDijitLayoutWidgetClass
    Procedure Resize(Const aWidth, aHeight, aTop, aLeft: Integer);
    //**
    Procedure Show;
    Constructor Build(Const aSession: BDojoSessionClass;
      Const aJSType: String = ''); Override;
    Destructor Burn; Override;
End;

Implementation

{ BDojoxFloatingPaneClass }

Procedure BDojoxFloatingPaneClass.SetDockable(aValue: Boolean);
Begin
  bDockable := aValue;
  SetConfig('dockable', aValue);
End;

Procedure BDojoxFloatingPaneClass.SetDuration(aValue: Integer);
Begin
  bDuration := aValue;
  SetConfig('duration', aValue);
End;

Procedure BDojoxFloatingPaneClass.SetMaxable(aValue: Boolean);
Begin
  bMaxable := aValue;
  SetConfig('maxable', aValue);
End;

Procedure BDojoxFloatingPaneClass.SetResizable(aValue: Boolean);
Begin
  bResizable := aValue;
  SetConfig('resizable', aValue);
End;

Procedure BDojoxFloatingPaneClass.SetResizeAxis(aValue: String);
Begin
  bResizeAxis := aValue;
  SetConfig('resizeAxis', aValue);
End;

Procedure BDojoxFloatingPaneClass.BringToTop;
Begin
  AddAjax('bringToTop();');
End;

Procedure BDojoxFloatingPaneClass.Close;
Begin
  AddAjax('close();');
End;

Procedure BDojoxFloatingPaneClass.Hide;
Begin
  AddAjax('hide();');
End;

Procedure BDojoxFloatingPaneClass.Maximize;
Begin
  AddAjax('maximize();');
End;

Procedure BDojoxFloatingPaneClass.Minimize;
Begin
  AddAjax('minimize();');
End;

Procedure BDojoxFloatingPaneClass.Resize(Const aWidth, aHeight, aTop,
  aLeft: Integer);
Begin
  AddAjax('resize({w:%d,h:%d,t:%d,l:%d});', [aWidth, aHeight, aTop, aLeft]);
End;

Procedure BDojoxFloatingPaneClass.Show;
Begin
  AddAjax('show();');
End;

Constructor BDojoxFloatingPaneClass.Build(Const aSession: BDojoSessionClass;
  Const aJSType: String);
Begin
  Inherited Build(aSession, 'dojox.layout.FloatingPane');
  ID := BuildDynamicElement;
  bSrcNodeRef := ID;
  aSession.AddDynamicCSS('/dojox/layout/resources/FloatingPane.css', TRUE);
  aSession.AddDynamicCSS('/dojox/layout/resources/ResizeHandle.css', TRUE);
End;

Destructor BDojoxFloatingPaneClass.Burn;
Begin
  Inherited Burn;
End;

End.

